package com.imut.hcdp.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.imut.hcdp.domain.HcdpPassenger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.imut.hcdp.common.Rst;

import com.imut.hcdp.domain.HcdpRole;
import com.imut.hcdp.service.IHcdpRoleService;



@RestController
@RequestMapping("/system/role")
public class HcdpRoleController
{
    @Autowired
    private IHcdpRoleService hcdpRoleService;



    @GetMapping("/list")
    public PageInfo list(HcdpRole hcdpRole, HttpServletRequest request)
    {
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        PageHelper.startPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        List<HcdpRole> list = hcdpRoleService.selectHcdpRoleList(hcdpRole);
        PageInfo<HcdpRole> pageInfo = (PageInfo<HcdpRole>)list;
        return pageInfo;
    }




    @GetMapping(value = "/{id}")
    public Rst getInfo(@PathVariable("id") Long id)
    {
        return Rst.success(hcdpRoleService.selectHcdpRoleById(id));
    }




    @PostMapping
    public Rst add(@RequestBody HcdpRole hcdpRole)
    {
        return Rst.success(hcdpRoleService.insertHcdpRole(hcdpRole));
    }




    @PutMapping
    public Rst edit(@RequestBody HcdpRole hcdpRole)
    {
        return Rst.success(hcdpRoleService.updateHcdpRole(hcdpRole));
    }




	@DeleteMapping("/{ids}")
    public Rst remove(@PathVariable Long[] ids)
    {
        return Rst.success(hcdpRoleService.deleteHcdpRoleByIds(ids));
    }
}
